package com.nstar.helloworld.view
{
	import mx.containers.VBox;
	import mx.events.FlexEvent;
	import com.nstar.base.controls.PanelFX;
	import com.nstar.base.controls.OkCancel;
	import com.nstar.base.event.ButtonBarEvent;
	import mx.managers.PopUpManager;
	import flash.events.MouseEvent;
	import mx.controls.LinkButton;
	import mx.containers.Form;
	import com.nstar.base.controls.ButtonAssets;
	import com.nstar.helloworld.model.Model;
	import flash.events.Event;
	import com.nstar.helloworld.controller.Controller;

	public class LoginClass extends VBox
	{
		public var btnLogin:LinkButton;
		public var btnRegister:LinkButton;
		public var frmLogin:Form;
		
		
		var login_caption:String = "登 录";
		var user_login:String = "用户登录";
		var login_state_yes:String = "用户状态 - 已登录";
		
		var model:Model = Model.getInstance();
				
		public function LoginClass()
		{
			//TODO: implement function
			super();
			this.addEventListener(FlexEvent.CREATION_COMPLETE,init);
		}
		
		function init(event:FlexEvent):void{
			btnLogin.addEventListener(MouseEvent.CLICK,loginHandler);
			btnRegister.addEventListener(MouseEvent.CLICK,registerHandler);
			
		}
		
		//登录检验
		function loginHandler(event:MouseEvent):void{
			switch(btnLogin.label){
				case user_login:
					frmLogin.height = 100;
					btnLogin.setStyle("icon",ButtonAssets.securityIcon32);
					btnLogin.label = login_caption;
					btnRegister.visible = true;
					break;
				case login_caption: 
					this.dispatchEvent( new Event( Event.SELECT) );
					break;
			}
		}
		
		//注册
		function registerHandler(event:MouseEvent):void{
			this.dispatchEvent( new Event( Event.CHANGE ) );
		}	
					
		
	}
}